﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataLayer;
using DataLayer.Entity;
namespace ConsoleApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            DataLayer.DataContext.CreateDataBase();
            var dbContext = DataContext.FactoryDataContext();
            
            //Criando uma entidade do tipo Person
            var person1 = dbContext.CreateObject<Person>();
            person1.Email = "higor@mail.com";
            person1.Name = "higor";
            dbContext.People.AddObject(person1);
            dbContext.SaveChanges();

            // Criando uma entidade do tipo AcademicPerson
            var academicperson1 = dbContext.CreateObject<AcademicPerson>();
            academicperson1.Email = "carlos@mail.com";
            academicperson1.Name = "carlos";
            academicperson1.Enrolment = "123";
            dbContext.People.AddObject(academicperson1);
            dbContext.SaveChanges();

            //Exibindo todas as ~entidades do tipo Person
            Console.WriteLine("People\n");
            foreach (var person in dbContext.People)
                Console.WriteLine("Name: " + person.Name + " Email:" + person.Email);
            
            Console.WriteLine("\n");
            //Exibindo todas as en
            Console.WriteLine("AcademicPeople\n");
            foreach (var academicPerson in dbContext.People.OfType<AcademicPerson>())
                Console.WriteLine("Name: " + academicPerson.Name + " Email:" + academicPerson.Email + " Enrolment" + academicPerson.Enrolment);

            Console.ReadKey();
        }
    }
}
